<?php
/**
 * Created by Zhy
 * User: Zhy
 * Date: 2019/3/1
 * Time: 10:37
 */

namespace app\admin\controller;


use think\Db;
use think\Request;

class About extends Base
{
    /**
     * 联系我们
     * @return mixed|\think\response\Json
     */
    public function phone(){
        if(Request::instance()->isPost()){
            $about_content = input('about_content');
            $res = Db::table('up_about')->where('about_id', 1)->update(['about_content' => $about_content]);
            if($res){
                return json(['code' => 200, 'msg' => '保存成功']);
            }else{
                return json(['code' => 100, 'msg' => '保存失败']);
            }
        }
        $about_content = Db::table('up_about')->where('about_id', 1)->value('about_content');
        $this->assign('about_content', $about_content);
        return $this->fetch('about/phone');
    }
    
    /**
     * 功能介绍
     * @return mixed|\think\response\Json
     */
    public function introduction(){
        if(Request::instance()->isPost()){
            $about_content = input('about_content');
            $res = Db::table('up_about')->where('about_id', 2)->update(['about_content' => $about_content]);
            if($res){
                return json(['code' => 200, 'msg' => '保存成功']);
            }else{
                return json(['code' => 100, 'msg' => '保存失败']);
            }
        }
        $about_content = Db::table('up_about')->where('about_id', 2)->value('about_content');
        $this->assign('about_content', $about_content);
        return $this->fetch('about/introduction');
    }
    
    /**
     * 法律声明
     * @return mixed|\think\response\Json
     */
    public function law(){
        if(Request::instance()->isPost()){
            $about_content = input('about_content');
            $res = Db::table('up_about')->where('about_id', 3)->update(['about_content' => $about_content]);
            if($res){
                return json(['code' => 200, 'msg' => '保存成功']);
            }else{
                return json(['code' => 100, 'msg' => '保存失败']);
            }
        }
        $about_content = Db::table('up_about')->where('about_id', 3)->value('about_content');
        $this->assign('about_content', $about_content);
        return $this->fetch('about/law');
    }
    
    /**
     * 平台协议
     * @return mixed|\think\response\Json
     */
    public function xy(){
        if(Request::instance()->isPost()){
            $about_content = input('about_content');
            $res = Db::table('up_about')->where('about_id', 4)->update(['about_content' => $about_content]);
            if($res){
                return json(['code' => 200, 'msg' => '保存成功']);
            }else{
                return json(['code' => 100, 'msg' => '保存失败']);
            }
        }
        $about_content = Db::table('up_about')->where('about_id', 4)->value('about_content');
        $this->assign('about_content', $about_content);
        return $this->fetch('about/xy');
    }
    
    /**
     * 用户协议
     * @return mixed|\think\response\Json
     */
    public function user(){
        if(Request::instance()->isPost()){
            $about_content = input('about_content');
            $res = Db::table('up_about')->where('about_id', 5)->update(['about_content' => $about_content]);
            if($res){
                return json(['code' => 200, 'msg' => '保存成功']);
            }else{
                return json(['code' => 100, 'msg' => '保存失败']);
            }
        }
        $about_content = Db::table('up_about')->where('about_id', 5)->value('about_content');
        $this->assign('about_content', $about_content);
        return $this->fetch('about/user');
    }
    
    /**
     * 隐私协议
     * @return mixed|\think\response\Json
     */
    public function yinsi(){
        if(Request::instance()->isPost()){
            $about_content = input('about_content');
            $res = Db::table('up_about')->where('about_id', 6)->update(['about_content' => $about_content]);
            if($res){
                return json(['code' => 200, 'msg' => '保存成功']);
            }else{
                return json(['code' => 100, 'msg' => '保存失败']);
            }
        }
        $about_content = Db::table('up_about')->where('about_id', 6)->value('about_content');
        $this->assign('about_content', $about_content);
        return $this->fetch('about/yinsi');
    }

    /**
     * @return mixed|\think\response\Json
     * 文本信息
     */
    public function information(){
        if(Request::instance()->isPost()){
            $about_content = input('about_content');
            $res = Db::table('up_about')->where('about_id', 7)->update(['about_content' => $about_content]);
            if($res){
                return json(['code' => 200, 'msg' => '保存成功']);
            }else{
                return json(['code' => 100, 'msg' => '保存失败']);
            }
        }
        $about_content = Db::table('up_about')->where('about_id', 7)->value('about_content');
        $this->assign('about_content', $about_content);
        return $this->fetch('about/information');
    }
    
    /**
     * 注册送抽奖次数
     * @return mixed|\think\response\Json
     */
    public function registDrawTimes(){
        if(Request::instance()->isPost()){
            $about_content = input('about_content');
            $res = Db::table('up_about')->where('about_id', 101)->update(['about_content' => $about_content]);
            if($res){
                return json(['code' => 200, 'msg' => '保存成功']);
            }else{
                return json(['code' => 100, 'msg' => '保存失败']);
            }
        }
        $about_content = Db::table('up_about')->where('about_id', 101)->value('about_content');
        $this->assign('about_content', $about_content);
        return $this->fetch('about/registdrawtimes');
    }
    
    /**
     * 签到规则
     * @return mixed|\think\response\Json
     */
    public function signRule(){
        if(Request::instance()->isPost()){
            $about_content = input('about_content');
            $res = Db::table('up_about')->where('about_id', 104)->update(['about_content' => $about_content]);
            if($res){
                return json(['code' => 200, 'msg' => '保存成功']);
            }else{
                return json(['code' => 100, 'msg' => '保存失败']);
            }
        }
        $about_content = Db::table('up_about')->where('about_id', 104)->value('about_content');
        $this->assign('about_content', $about_content);
        return $this->fetch('about/signrule');
    }
    

}